package com.ycsj.goldmedalnewconcept.utils;

import com.ycsj.goldmedalnewconcept.R;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.widget.Toast;


/**
 * 创建日期：2017/11/12  10:30
 * 描述:显示加载框的帮助类
 * 作者:张伟
 */

public class UiHelper {

    private static Dialog mProgressDialog;
    private static Toast toast;

    public static synchronized void showDialog(Context context, String message) {
        final LoadingDialog dialog = new LoadingDialog(context,
                R.style.CustomProgressDialog);
        //设置点击空白处不消失
        dialog.setCanceledOnTouchOutside(false);
        dialog.setMsg(message);
        dialog.setCancelable(true);
        mProgressDialog = dialog;
        if (mProgressDialog != null)
            mProgressDialog.show();
    }

    public static synchronized void dismissDialog() {
        if (null != mProgressDialog && mProgressDialog.isShowing()) {
            try {
                mProgressDialog.dismiss();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }

        }
    }

    /**
     * 自定义的弹吐司的方法
     */
    public static void toast(Context context, String content) {
        toast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
    }
}
